Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
The dashify npm package is a utility that converts a string with spaces or camelCase into a dash-separated string. This is particularly useful for creating URL slugs, CSS class names, or other identifiers that require a specific format.
Convert camelCase to dash-case
This feature allows you to convert a camelCase string into a dash-separated string. This is useful for transforming variable names or other identifiers into a format suitable for URLs or CSS class names.
const dashify = require('dashify');
const result = dashify('camelCaseString');
console.log(result); // Output: camel-case-string
Convert space-separated string to dash-case
This feature allows you to convert a space-separated string into a dash-separated string. This is useful for creating URL slugs or other identifiers from user input or other sources.
const dashify = require('dashify');
const result = dashify('space separated string');
console.log(result); // Output: space-separated-string
Convert mixed case and space-separated string to dash-case
This feature allows you to convert a string that contains both camelCase and spaces into a dash-separated string. This is useful for normalizing various types of input into a consistent format.
const dashify = require('dashify');
const result = dashify('MixedCase and space separated');
console.log(result); // Output: mixed-case-and-space-separated
The slugify package converts strings into URL-friendly slugs. It offers more customization options compared to dashify, such as handling special characters and providing options for different separator characters.
The kebab-case package converts camelCase or space-separated strings into kebab-case (dash-separated) strings. It is similar to dashify but focuses specifically on converting to kebab-case.
The lodash.kebabcase function from the lodash library converts strings to kebab-case. It is part of the larger lodash utility library, which offers a wide range of functions for manipulating and working with data.
Convert a camelcase or space-separated string to a dash-separated string.
I'm using this for converting object keys to dash-case. Most slugify libs are too heavy for this, so I made this as a fast and light alternative.
Install with npm:
$ npm install dashify --save
var dashify = require('dashify');
dashify('fooBar');
//=> 'foo-bar'
dashify('fooBarBaz');
//=> 'foo-bar-baz'
dashify('foo bar');
//=> 'foo-bar'
dashify('foo barBaz');
//=> 'foo-bar-baz'
dashify('foo barBaz quux');
//=> 'foo-bar-baz-quux'
Some other awesome string libs:
Install dev dependencies:
$ npm install -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
If this project doesn't do what you need, please let us know!
Jon Schlinkert
Copyright © 2015-2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 23, 2016.
FAQs
Convert a camelcase or space-separated string to a dash-separated string. ~12 sloc, fast, supports diacritics.
The npm package dashify receives a total of 0 weekly downloads. As such, dashify popularity was classified as not popular.
We found that dashify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.